package com.kara.woodAgent.agent.model.impl;

import com.kara.woodAgent.agent.model.ModelProvider;
import dev.langchain4j.exception.ModelNotFoundException;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.chat.StreamingChatLanguageModel;
import dev.langchain4j.model.embedding.EmbeddingModel;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.model.openai.OpenAiStreamingChatModel;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
@ConditionalOnProperty(prefix = "model.use",name = "enable",havingValue = "kimi")
@Component
public class KimiModelProvider implements ModelProvider {

    @Value("${model.kimi.key}")
    private String apiKey;

    @Value("${model.kimi.baseUrl}")
    private String baseUrl;

    @Value("${model.kimi.name}")
    private String model;


    private OpenAiChatModel chatModel;

    @PostConstruct
    public void init() {
        chatModel = OpenAiChatModel.builder()
                .apiKey(apiKey)
                .baseUrl(baseUrl)
                .modelName(model)
                .build();
    }


    @Override
    public ChatLanguageModel getChatModel() {
        return chatModel;
    }



    @Override
    public StreamingChatLanguageModel getStreamingChatModel() {
        return OpenAiStreamingChatModel
                .builder()
                .apiKey(apiKey)
                .baseUrl(baseUrl)
                .modelName(model).build();
    }
}
